package com.zbkj.admin.controller.merchant.monitor;

import com.zbkj.common.model.admin.SystemAdmin;
import com.zbkj.common.request.monitor.ZfbMonitorEquipmentAddReq;
import com.zbkj.common.request.monitor.ZfbMonitorEquipmentBindProductReq;
import com.zbkj.common.request.monitor.ZfbMonitorEquipmentDeleteReq;
import com.zbkj.common.request.monitor.ZfbMonitorEquipmentSearchReq;
import com.zbkj.common.result.CommonResult;
import com.zbkj.common.utils.SecurityUtil;
import com.zbkj.service.service.monitor.IZfbMonitorEquipmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: MerchantMonitorEquipmentController
 * @Description: TODO
 * @Author: fanbing
 * @Date: 2024/6/29 14:26
 * @Version: V1.0
 **/
@Slf4j
@RestController
@RequestMapping("api/admin/merchant/monitor/equipment")
@Api(tags = "商户端监控设备")
public class MerchantMonitorEquipmentController {

    @Autowired
    private IZfbMonitorEquipmentService zfbMonitorEquipmentService;

    @PreAuthorize("hasAuthority('merchant:montior:equiopment:page:list')")
    @ApiOperation(value = "商户监控设备列表") //配合swagger使用
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public CommonResult getList(@RequestBody @Validated ZfbMonitorEquipmentSearchReq searchRequest) {
        return CommonResult.success(zfbMonitorEquipmentService.getMerchantPageList(searchRequest, SecurityUtil.getLoginUserVo().getUser()));
    }


    @PreAuthorize("hasAuthority('merchant:montior:equiopment:add')")
    @ApiOperation(value = "商户新增监控设备列表") //配合swagger使用
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public CommonResult add(@RequestBody @Validated ZfbMonitorEquipmentAddReq addRequest) {
        return CommonResult.success(zfbMonitorEquipmentService.addMonitorEquipment(addRequest, SecurityUtil.getLoginUserVo().getUser()));
    }


    @PreAuthorize("hasAuthority('merchant:montior:equiopment:delete')")
    @ApiOperation(value = "商户新增监控设备列表") //配合swagger使用
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public CommonResult delete(@RequestBody @Validated ZfbMonitorEquipmentDeleteReq delRequest) {
        return CommonResult.success(zfbMonitorEquipmentService.deleteMonitorEquipment(delRequest, SecurityUtil.getLoginUserVo().getUser()));
    }

    @PreAuthorize("hasAuthority('merchant:montior:equiopment:bind:product')")
    @ApiOperation(value = "商户监控设备绑定商品") //配合swagger使用
    @RequestMapping(value = "/bindProduct", method = RequestMethod.POST)
    public CommonResult bindProduct(@RequestBody @Validated ZfbMonitorEquipmentBindProductReq bindProductRequest) {
        return CommonResult.success(zfbMonitorEquipmentService.merchantBindProduct(bindProductRequest, SecurityUtil.getLoginUserVo().getUser()));
    }
}
